package com.cw.jeeyt.dao.impl.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.common.Order;
import com.cw.jeeyt.dao.intf.api.ApiDataEntryDao;
import com.cw.jeeyt.dao.mapper.api.ApiDataEntryMapper;
import com.cw.jeeyt.dao.model.api.ApiDataEntryDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * 接口字段信息 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class ApiDataEntryDaoImpl implements ApiDataEntryDao {
    @Autowired
    private ApiDataEntryMapper apiDataEntryMapper;

    /**
     * 新增接口字段信息
     *
     * @param apiDataEntry
     * @return 整数
     */
    public Integer insert(ApiDataEntryDo apiDataEntry) {
        return apiDataEntryMapper.insert(apiDataEntry);
    }

    /**
     * 新增接口字段信息不为空的字段
     *
     * @param apiDataEntry
     * @return 整数
     */
    public Integer insertSelective(ApiDataEntryDo apiDataEntry) {
        return apiDataEntryMapper.insertSelective(apiDataEntry);
    }

    /**
     * 删除接口字段信息
     *
     * @param apiDataEntry
     */
    public void delete(ApiDataEntryDo apiDataEntry) {
        apiDataEntryMapper.delete(apiDataEntry);
    }

    /**
     * 修改接口字段信息不为null的字段
     *
     * @param apiDataEntry
     */
    public void updateSelective(ApiDataEntryDo apiDataEntry) {
        apiDataEntryMapper.updateSelective(apiDataEntry);
    }

    /**
     * 修改接口字段信息
     *
     * @param apiDataEntry
     */
    public void update(ApiDataEntryDo apiDataEntry) {
        apiDataEntryMapper.update(apiDataEntry);
    }

    /**
     * 根据主键查询接口字段信息
     *
     * @return 接口字段信息
     */
    public ApiDataEntryDo getById(Long id) {
        return apiDataEntryMapper.getById(id);
    }

    /**
     * 查询所有接口字段信息
     *
     * @return 接口字段信息集合
     */
    public List<ApiDataEntryDo> queryApiDataEntryList() {
        return apiDataEntryMapper.queryApiDataEntryList();
    }

    /**
     * 分页查询接口字段信息
     *
     * @param apiDataEntry 查询条件
     * @param startRow 开始条数
     * @param pageSize 每页长度
     * @return 接口字段信息集合
     */
    public PageInfo<ApiDataEntryDo> queryByPage(ApiDataEntryDo apiDataEntry, Integer startRow, Integer pageSize,
        Order order) {
        PageHelper.startPage(PageUtil.calPageNum(startRow, pageSize), pageSize);
        return new PageInfo<>(apiDataEntryMapper.queryByPage(apiDataEntry, order));
    }

    /**
     * 批量新增接口字段信息
     *
     * @param adeList
     * @throws Exception
     */
    public void insertBat(List<ApiDataEntryDo> adeList) {
        apiDataEntryMapper.insertBat(adeList);
    }

    /**
     * 根据字段编码、字段名称、字段类型查询接口字段信息
     *
     * @param columnCode
     * @param columnName
     * @param columnSqlType
     * @return
     */
    public ApiDataEntryDo queryByCondition(String columnCode, String columnName, String columnSqlType) {
        return apiDataEntryMapper.queryByCondition(columnCode, columnName, columnSqlType);
    }

    /**
     * 分页查询导入接口字段信息
     *
     * @param apiDataEntry
     * @param startNum
     * @param pageSize
     * @param order
     * @param objId
     * @return
     */
    public PageInfo<ApiDataEntryDo> queryImportByPage(ApiDataEntryDo apiDataEntry, Integer startNum, Integer pageSize,
        Order order, Long objId) {
        PageHelper.startPage(PageUtil.calPageNum(startNum, pageSize), pageSize);
        return new PageInfo<>(apiDataEntryMapper.queryImportByPage(apiDataEntry, order, objId));
    }
}
